import 'package:app/pages/message/widget/StickyTabBarDelegate.dart';
import 'package:app/shared/constants/common.dart';
import 'package:app/pages/message/widget/list.dart';
import 'package:app/pages/message/widget/notice.dart';
import 'package:flutter/material.dart';

class MessagePage extends StatefulWidget {
  MessagePage({Key? key}) : super(key: key);

  @override
  _MessagePageState createState() => _MessagePageState();
}

class _MessagePageState extends State<MessagePage>
    with SingleTickerProviderStateMixin {
  late TabController tabController;

  @override
  void initState() {
    super.initState();
    this.tabController = TabController(length: 2, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    return SafeArea(
        child: Scaffold(
      body: CustomScrollView(
        slivers: <Widget>[
          SliverPersistentHeader(
            pinned: true,
            delegate: StickyTabBarDelegate(
              child: TabBar(
                indicatorColor: Colors.transparent,
                labelColor: Colors.black,
                controller: this.tabController,
                labelStyle:
                    TextStyle(fontSize: 22, fontWeight: FontWeight.bold),
                unselectedLabelStyle:
                    TextStyle(fontSize: 16, fontWeight: FontWeight.normal),
                tabs: <Widget>[
                  Tab(text: '消息'),
                  Tab(text: '动态'),
                ],
              ),
            ),
          ),
          SliverFillRemaining(
            child: TabBarView(
              controller: this.tabController,
              children: <Widget>[
                ListView(
                  padding:
                      EdgeInsets.symmetric(horizontal: sDefaultMarginPadding),
                  children: [NoticeCom(), ListCom()],
                ),
                ListView(
                  padding: EdgeInsets.symmetric(
                      horizontal: sDefaultMarginPadding * 3),
                ),
              ],
            ),
          ),
        ],
      ),
    ));
  }
}
